package com.sky.mapper;

import com.sky.entity.Category;
import org.apache.ibatis.annotations.*;
import org.springframework.stereotype.Component;

import java.util.List;
import java.util.Set;

@Mapper
@Component
public interface CategoryMapper {

    //分页查询
    List<Category> list(String name, Integer type);

    //修改分类
    @Update(" update category set name =#{name}, sort=#{sort}, type = #{type} where id=#{id}")
    Integer updateCate(Category category);

    //启用、禁用分类
    @Update("update category set status=#{status} where id=#{id}")
    void updatus(Category category);

    //新增分类
    @Insert("Insert into category (name, sort, type) values (#{name}, #{sort}, #{type})")
    Integer save(Category category);

    //根据id删除分类
    @Delete("delete from category where id=#{id} ")
    Integer remove(Long id);

    //根据id获取分类
    @Select("select * from category where id = #{id} ")
    Category selectById(Long id);

    //根据类型查询分类
    @Select("select * from category where type =#{type}")
    List<Category> getByType(Integer type);

    List<Category> findByIds(Set<Long> ids);

    @Select("select * from category")
    List<Category> selectAll();

}
